﻿using HelenServer.BugEngine.Contracts;

namespace HelenServer.BugEngine.Controllers;

[ApiController]
[Route("[controller]")]
public class ProductController : ControllerBase
{
    private readonly IProductService _service;

    public ProductController(IProductService service)
    {
        _service = service;
    }

    [HttpGet]
    public async Task<IActionResult> GetAllAsync()
    {
        return this.Ok(await _service.GetAllAsync(HttpContext.RequestAborted));
    }

    [HttpPost]
    public async Task<IActionResult> InsertAsync()
    {
        return this.Ok(await _service.InsertAsync(HttpContext.RequestAborted));
    }

    [HttpPut]
    public async Task<IActionResult> UpdateAsync()
    {
        return this.Ok(await _service.UpdateAsync(null, HttpContext.RequestAborted));
    }

    [HttpDelete]
    public async Task<IActionResult> DeleteAsync()
    {
        var operation = HttpContext.GetOperation("5");

        return this.Ok(await _service.DeleteAsync(operation, HttpContext.RequestAborted));
    }
}